package cn.zn.framework.common.utils;

import org.apache.http.HttpStatus;

import java.util.HashMap;
import java.util.Map;

/**
 * 百度大屏数据返回
 *
 * @author ZN
 */
public class ResultBaiduSugar extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;

    public ResultBaiduSugar() {
        put("status", 0);
        put("msg", "");
    }

    public static ResultBaiduSugar error() {
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常，请联系管理员");
    }

    public static ResultBaiduSugar error(String msg) {
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
    }

    public static ResultBaiduSugar error(int code, String msg) {
        ResultBaiduSugar r = new ResultBaiduSugar();
        r.put("status", code);
        r.put("msg", msg);
        return r;
    }

    public static ResultBaiduSugar ok(String msg) {
        ResultBaiduSugar r = new ResultBaiduSugar();
        r.put("msg", msg);
        return r;
    }

    public static ResultBaiduSugar ok(Map<String, Object> map) {
        ResultBaiduSugar r = new ResultBaiduSugar();
        r.putAll(map);
        return r;
    }

    public static ResultBaiduSugar ok() {
        return new ResultBaiduSugar();
    }

    @Override
    public ResultBaiduSugar put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}
